/*
******************************************************************************************************* 
**  Copyright (C) 2019, 苏州检易生物科技有限公司 
**  All rights reserved. 
** 
**  FileName:       	pump.h
**  Description:	
**  Author:        	 
**  Version				v0.1
**  Date:           	2019-11-19
**	Function List： 
**  History:         
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*                                              	防止重复包含
*********************************************************************************************************
*/

#ifndef _PUMP_H_
#define _PUMP_H_
/*
*********************************************************************************************************
*                                              	调试开关
*********************************************************************************************************
*/



/*
*********************************************************************************************************
*                                              	头文件
*********************************************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#include "stm32h7xx_hal.h"

#include <rtthread.h>
#include "act.h"
#include "motor_cfg_default.h"
#include "system_cfg.h"

/*
*********************************************************************************************************
*                                              	宏定义
*********************************************************************************************************
*/

#define		PUMP_NOT_FIND		(0xFF)

#define		PUMP_NODE_MAX		(100)



#define ACT_PARA_DEVICE_INDEX		0
#define ACT_PARA_ONOFF_INDEX		1

//#define MUTIPLE_DIA_PUMP
/*
*********************************************************************************************************
*                                              枚举和结构体类型定义
*********************************************************************************************************
*/



typedef enum{
	PUMP_ERR_NONE,
	PUMP_ERR_INIT,
	PUMP_ERR_ON,
	PUMP_ERR_OFF,
}pump_err_t;

typedef enum{
	TRI_VALVE_CLEAN_1 = 0,
	TRI_VALVE_CLEAN_2 = 1,
	TRI_VALVE_CLEAN_3 = 2,
	TRI_VALVE_POUR_WASTE = 3,
	
	TWO_VALVE_SP = 4,
	TWO_VALVE_RP = 5,
	TWO_VALVE_SP_CLEAN = 6,
	TWO_VALVE_RP_CLEAN = 7,
	TWO_VALVE_SP_ALKALI = 8,
	
	TWO_VALVE_RA_1 = 9,
	TWO_VALVE_RA_2 = 10,
	TWO_VALVE_RB_1 = 11,
	TWO_VALVE_RB_2 = 12,
#ifdef MUTIPLE_DIA_PUMP
	DIA_PUMP_INSIDE_CLEAN = 13,
	DIA_PUMP_OUTSIDE_CLEAN = 14,
	DIA_PUMP_ALKALI = 15,
	DIA_PUMP_SP_WASTE = 16,
	DIA_PUMP_RP_WASTE = 17,
	DIA_PUMP_SUCK = 18,
#else
	DIA_PUMP_INSIDE_CLEAN = 13,
	DIA_PUMP_OUTSIDE_CLEAN = 14,
	DIA_PUMP_ALKALI = 15,
	DIA_PUMP_SP_WASTE = 16,
	DIA_PUMP_RP_WASTE = 17,
	DIA_PUMP_POUR_WASTE = 18,
#endif
//	DIA_PUMP_TUBE_SUCK = 19,
	
	
	LOCK_TUBE_LEFT =	19,
	LOCK_TUBE_RIGHT = 20,
	LOCK_WASTE_TUBE_LEFT = 21,
	LOCK_WASTE_TUBE_RIGHT = 22,
	LOCK_RACK = 23,
	
}pump_id_t;

typedef enum{
	PUMP_CH_1,
	PUMP_CH_2,
	PUMP_CH_3,
	PUMP_CH_4,
	
	PUMP_CH_5,
	PUMP_CH_6,
	PUMP_CH_7,
	PUMP_CH_8,
	
	PUMP_CH_9,
	PUMP_CH_10,
	PUMP_CH_11,
	PUMP_CH_12,
	
	PUMP_CH_13,
	PUMP_CH_14,
	PUMP_CH_15,
	PUMP_CH_16,
	
	PUMP_CH_17,
	PUMP_CH_18,
	PUMP_CH_19,
	PUMP_CH_20,
	
	PUMP_CH_21,
	PUMP_CH_22,
	PUMP_CH_23,
	PUMP_CH_24,
	
	PUMP_CH_25,
	PUMP_CH_26,
	PUMP_CH_27,
	PUMP_CH_28,
	
	PUMP_CH_29,
	PUMP_CH_30,
	PUMP_CH_31,
	PUMP_CH_32,
}pump_ch_t;


typedef enum{
	PUMP_STATE_INIT,
	PUMP_STATE_RDY,
	PUMP_STATE_ON,
	PUMP_STATE_OFF,
}pumpt_state_t;


typedef enum{
	IO_OFF,
	IO_ON
}pump_io_flag_t;

typedef enum{
	PUMP_DISABLE,
	PUMP_ENABLE,
}pumt_en_t;
typedef enum{
	PUMP_LOGIC_NORMAL,
	PUMP_LOGIC_REVERSE,
}pump_logic_t;


typedef struct{
	uint8_t		pump_id;			//pump名称
	uint8_t		on_cnt;				//打开次数
	pump_cfg_t*		p_cfg;	
	uint32_t* 	board_value;		//发送内容
//	OS_MUTEX*	p_mutex;			//互斥信号量
}pump_t;

/*
*********************************************************************************************************
*                                              	全局变量声明
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                              	函数声明
*********************************************************************************************************
*/
pump_err_t pump_init(void);

uint8_t 	pump_on(pump_id_t id, void* p_task_cb);

uint8_t 	pump_off(pump_id_t id, void* p_task_cb);

uint8_t		pump_set(pump_id_t id, pump_io_flag_t);
#endif
